package view
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class PricePanle extends Sprite
	{
		private static var instance:PricePanle; 
		
		[Embed(source="assets/navigation/price.png")]
		private var priceCls:Class;
		private var priceBitmap:Bitmap;
		private var txt:TextField;
		private var priceStr:String;
		private var sizeStr:String;
		private var priceObj:Object;
		private var typeObj:Object;
		public function PricePanle()
		{
			if(instance!=null) throw new Error("Error: Singletons can only be instantiated via getInstance() method!");  
			PricePanle.instance = this;  
			init();
		}
		public static function getInstance():PricePanle  
		{  
			if(instance==null)  instance = new PricePanle();  
			return instance; 
		}
		private function init():void{
			priceBitmap = new priceCls();
			this.addChild(priceBitmap);
			
			txt = new TextField;
			txt.width = 320;
			txt.height = 50;
			txt.multiline = true;
			txt.x = 52;
			txt.y = 5;
			this.addChild(txt);
			priceStr = "<p><font size='16' color='#666666'>尺寸：未选择</font></p>";
			sizeStr = "<p><font size='16' color='#666666'>画框：未选择</font></p>"
			txt.htmlText = priceStr + sizeStr;
		}
		public function setPriceType(pObj:Object):void{
			if(pObj)
				this.priceObj = pObj;
			/*if(tObj)
				this.typeObj = tObj;*/
			var str:String;
			if(priceObj){
				str = "<p><font size='16' color='#666666'>尺寸：" 
					+ priceObj.name + priceObj.w + " * " + priceObj.h + "，" + priceObj.price + "￥</font></p>";
				str += "<p><font size='16' color='#666666'>画框：价格" + priceObj.frameprice + "￥</font></p>"
			}else{
				str = priceStr + sizeStr;
			}
			/*
			if(typeObj){
				str += "<p><font size='16' color='#666666'>画框：价格" + typeObj.price + "</font></p>"
			}else{
				str += sizeStr;
			}*/
			
			txt.htmlText = str;
			
		}
	}
}